/***
 * @Author: LVGRAPE
 * @Date: 2023-12-02 18:19:06
 * @LastEditTime: 2023-12-02 19:33:11
 * @LastEditors: LVGRAPE
 * @Description:
 * @FilePath: \zino-fc-v4\ZINO\hardware\lsm6dsr\lsm6dsr_regmap.h
 * @要啥没啥，爱咋咋的
 */

#ifndef __LSM6DSR_REG_H_
#define __LSM6DSR_REG_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

    enum LSM6DSR_REGISTER_MAP {
        LSM6DSR_REG_INDEX_FUNC_CFG_ACCESS = 0X01,//Enable embedded functions register (r/w)
        LSM6DSR_REG_INDEX_PIN_CTRLR = 0X02,
        LSM6DSR_REG_INDEX_S4S_TPH_L = 0X04,
        LSM6DSR_REG_INDEX_S4S_TPH_H = 0X05,
        LSM6DSR_REG_INDEX_S4S_RR = 0X06,
        LSM6DSR_REG_INDEX_FIFO_CTRL1 = 0X07,
        LSM6DSR_REG_INDEX_FIFO_CTRL2 = 0X08,
        LSM6DSR_REG_INDEX_FIFO_CTRL3 = 0X09,
        LSM6DSR_REG_INDEX_FIFO_CTRL4 = 0X0A,
        LSM6DSR_REG_INDEX_COUNTER_BDR_REG1 = 0X0B,
        LSM6DSR_REG_INDEX_COUNTER_BDR_REG2 = 0X0C,
        LSM6DSR_REG_INDEX_INT1_CTRL = 0X0D,
        LSM6DSR_REG_INDEX_INT2_CTRL = 0X0E,
        LSM6DSR_REG_INDEX_WHO_AM_I = 0X0F,
        LSM6DSR_REG_INDEX_CTRL1_XL = 0X10,
        LSM6DSR_REG_INDEX_CTRL2_G = 0X11,
        LSM6DSR_REG_INDEX_CTRL3_C = 0X12,
        LSM6DSR_REG_INDEX_CTRL4_C = 0X13,
        LSM6DSR_REG_INDEX_CTRL5_C = 0X14,
        LSM6DSR_REG_INDEX_CTRL6_C = 0X15,
        LSM6DSR_REG_INDEX_CTRL7_G = 0X16,
        LSM6DSR_REG_INDEX_CTRL8_XL = 0X17,
        LSM6DSR_REG_INDEX_CTRL9_XL = 0X18,
        LSM6DSR_REG_INDEX_CTRL10_C = 0X19,
        LSM6DSR_REG_INDEX_ALL_INT_SRC = 0X1A,
        LSM6DSR_REG_INDEX_WAKE_UP_SRC = 0X1B,
        LSM6DSR_REG_INDEX_TAP_SRC = 0X1C,
        LSM6DSR_REG_INDEX_D6D_SRC = 0X1D,
        LSM6DSR_REG_INDEX_STATUS_REG = 0X1E,
        LSM6DSR_REG_INDEX_OUT_TEMP_L = 0X20,
        LSM6DSR_REG_INDEX_OUT_TEMP_H = 0X21,
        LSM6DSR_REG_INDEX_OUTX_L_G = 0X22,
        LSM6DSR_REG_INDEX_OUTX_H_G = 0X23,
        LSM6DSR_REG_INDEX_OUTY_L_G = 0X24,
        LSM6DSR_REG_INDEX_OUTY_H_G = 0X25,
        LSM6DSR_REG_INDEX_OUTZ_L_G = 0X26,
        LSM6DSR_REG_INDEX_OUTZ_H_G = 0X27,
        LSM6DSR_REG_INDEX_OUTX_L_A = 0X28,
        LSM6DSR_REG_INDEX_OUTX_H_A = 0X29,
        LSM6DSR_REG_INDEX_OUTY_L_A = 0X2A,
        LSM6DSR_REG_INDEX_OUTY_H_A = 0X2B,
        LSM6DSR_REG_INDEX_OUTZ_L_A = 0X2C,
        LSM6DSR_REG_INDEX_OUTZ_H_A = 0X2D,
        LSM6DSR_REG_INDEX_EMB_FUNC_STATUS_MAINPAGE = 0X35,
        LSM6DSR_REG_INDEX_FSM_STATUS_A_MAINPAGE = 0X36,
        LSM6DSR_REG_INDEX_FSM_STATUS_B_MAINPAGE = 0X37,
        LSM6DSR_REG_INDEX_STATUS_MASTER_MAINPAGE = 0X39,
        LSM6DSR_REG_INDEX_FIFO_STATUS1 = 0X3A,
        LSM6DSR_REG_INDEX_FIFO_STATUS2 = 0X3B,
        LSM6DSR_REG_INDEX_TIMESTAMPO = 0X40,
        LSM6DSR_REG_INDEX_TIMESTAMP1 = 0X41,
        LSM6DSR_REG_INDEX_TIMESTAMP2 = 0X42,
        LSM6DSR_REG_INDEX_TIMESTAMP3 = 0X43,
        LSM6DSR_REG_INDEX_TAP_CFGO = 0X56,
        LSM6DSR_REG_INDEX_TAP_CFG1 = 0X57,
        LSM6DSR_REG_INDEX_TAP_CFG2 = 0X58,
        LSM6DSR_REG_INDEX_TAP_THS_6D = 0X59,
        LSM6DSR_REG_INDEX_INT_DUR2 = 0X5A,
        LSM6DSR_REG_INDEX_WAKE_UP_THS = 0X5B,
        LSM6DSR_REG_INDEX_WAKE_UP_DUR = 0X5C,
        LSM6DSR_REG_INDEX_FREE_FALL = 0X5D,
        LSM6DSR_REG_INDEX_MD1_CFG = 0X5E,
        LSM6DSR_REG_INDEX_MD2_CFG = 0X5F,
        LSM6DSR_REG_INDEX_S4S_ST_CMD_CODE = 0X60,
        LSM6DSR_REG_INDEX_S4S_DT_REG = 0X61,
        LSM6DSR_REG_INDEX_I3C_BUS_AVB = 0X62,
        LSM6DSR_REG_INDEX_INTERNAL_FREQ_FINE = 0X63,
        LSM6DSR_REG_INDEX_INT_OIS = 0X6F,
        LSM6DSR_REG_INDEX_CTRL1_0IS = 0X70,
        LSM6DSR_REG_INDEX_CTRL2_OIS = 0X71,
        LSM6DSR_REG_INDEX_CTRL3_OIS = 0X72,
        LSM6DSR_REG_INDEX_X_OFS_USR = 0X73,
        LSM6DSR_REG_INDEX_Y_OFS_USR = 0X74,
        LSM6DSR_REG_INDEX_Z_OFS_USR = 0X75,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_TAG = 0X78,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_X_L = 0X79,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_X_H = 0X7A,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_Y_L = 0X7B,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_Y_H = 0X7C,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_Z_L = 0X7D,
        LSM6DSR_REG_INDEX_FIFO_DATA_OUT_Z_H = 0X7E,
    };

        struct LSM6DSR_FUNC_CFG_ACCESS{//(01h)
            uint8_t reserved:6;/**This bit must be set to '0' for the correct operation of the device. */
            uint8_t SHUB_REG_ACCESS:1;/**Enable access to the sensor hub (I²C master) registers.Default value: 0 */
            uint8_t FUNC_CFG_ACCESS:1;/**Enable access to the embedded functions configuration registers.Default value: 0 */
        };
        struct LSM6DSR_PIN_CTRL{//(02h)
            uint8_t reserved:6;/**This bit must be set to '1' for the correct operation of the device. */
            uint8_t SDO_PU_EN:1;/**Disable pull-up on both OCS_Aux and SDO_Aux pins. Default value: 0 */
            uint8_t OIS_PU_DIS:1;/**Enable pull-up on SDO pin. Default value: 0 */
        };
        struct LSM6DSR_S4S_TPH_L{//(04H)
        uint8_t TPH_L_0:1;
        uint8_t TPH_L_1:1;
        uint8_t TPH_L_2:1;
        uint8_t TPH_L_3:1;
        uint8_t TPH_L_4:1;
        uint8_t TPH_L_5:1;
        uint8_t TPH_L_6:1;/**S4S timeframe expressed in number of samples as described in the equation below. */
        uint8_t TPH_H_SEL:1;/**Chooses if the TPH formula must be taken into account (see equation below). */
        };
        struct LSM6DSR_FIFO_CTRL1{//07h
            uint8_t WTM0:1;
            uint8_t WTM1:1;
            uint8_t WTM2:1;
            uint8_t WTM3:1;
            uint8_t WTM4:1;
            uint8_t WTM5:1;
            uint8_t WTM6:1;
            uint8_t WTM7:1;
        };
        struct LSM6DSR_FIFO_CTRL2{//08h
            uint8_t WTM8:1;
            uint8_t UNCOPTR_RATE_0:1;
            uint8_t UNCOPTR_RATE_1:1;
            uint8_t RSV1:1;//must be 0
            uint8_t ODRCHG_EN:1;
            uint8_t RSV2:1;//must be 0
            uint8_t FIFO_COMPR_RT_EN:1;
            uint8_t STOP_ON_WTM:1;
        };
        enum{
            LSM6DSR_ACC_ODR_2G=0,
            LSM6DSR_ACC_ODR_4G,
            LSM6DSR_ACC_ODR_8G,
            LSM6DSR_ACC_ODR_16G,
                      
        };
        typedef union LSM6DSR_CTRL1_XL_DSC//10H
        {
            struct{
                uint8_t rsv0:1;
                /**
                 * Accelerometer high-resolution selection
                 * (0: output from first stage digital filtering selected (default);
                 * 1: output from LPF2 second filtering stage selected) */
                uint8_t LPF2_XL_EN:1;
                /**
                 * Accelerometer full-scale selection. Default value: 00
                 * (00: ±2 g; 01: ±16 g; 10: ±4 g; 11: ±8 g)
                 */
                uint8_t FS_XL:2;
                /**
                 * @brief Accelerometer ODR selection
                 * 0: power-down
                 * 1: 12.5Hz
                 * 2: 26Hz
                 * 3: 52Hz
                 * 4: 104Hz
                 * 5: 208Hz
                 * 6: 416Hz
                 * 7: 833Hz
                 * 8: 1.66KHz
                 * 9: 3.33KHz
                 * 10: 6.66KHz
                 * 11: 1.6Hz
                 */
                uint8_t ODR_XL:4;
            };
            uint8_t ctrl1_xl;
        }LSM6DSR_CTRL1_XL_T;
        typedef union LSM6DSR_CTRL2_G_DSC//(11h)
        {
            struct{
                /**
                 * @brief Selects gyro chain full-scale ±4000 dps
                 * (0: FS selected through bits FS[1:0]_G or FS_125;
                 * 1: FS set to ±4000 dps)
                 * 
                 */
                uint8_t FS_4000:1;
                /**
                 * @brief Selects gyro chain full-scale ±125 dps
                 * (0: FS selected through bits FS[1:0]_G;
                 * 1: FS set to ±125 dps)
                 * 
                 */
                uint8_t FS_125:1;
                /**
                 * @brief Gyroscope chain full-scale selection
                 * (00: ±250 dps;
                 * 01: ±500 dps;
                 * 10: ±1000 dps;
                 * 11: ±2000 dps)
                 * 
                 */
                uint8_t FS_G:2;
                /**
                 * @brief Gyroscope output data rate selection. Default value: 0000
                 * ODR_G[3:0]
                 * 0: power-down
                 * 1: 12.5Hz
                 * 2: 26Hz
                 * 3: 52Hz
                 * 4: 104Hz
                 * 5: 208Hz
                 * 6: 416Hz
                 * 7: 833Hz
                 * 8: 1.66KHz
                 * 9: 3.33KHz
                 * 10: 6.66KHz
                 * 11: Not available
                 * 
                 */
                uint8_t ODR_G:4;
                 
            };
            uint8_t ctrl2;
        }LSM6DSR_CTRL2_G_T;
        typedef union LSM6DSR_CTRL3_C_DSC//(12h)
        {
            struct{
                /**
                 * @brief Enable/disable temperature sensor
                 * (0: temperature sensor disabled;
                 * 1: temperature sensor enabled)
                 * 
                 */
                uint8_t TEMP_EN:1;
                /**
                 * @brief Enable/disable gyroscope
                 * (0: gyroscope disabled;
                 * 1: gyroscope enabled)
                 *
        {
            /* data */
        };
        
        
        
#ifdef __cplusplus
}
#endif // __cplusplus
#endif
